<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="my" uri="/my-tags"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'search.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="images/main.css">
<link rel="stylesheet" type="text/css" href="images/pagingExt.css">
<script type="text/javascript" src="images/jquery.js"></script>
<script type="text/javascript">
$(function(){
	$("#submit").click(function(){
		//alert($("#wd").val().length);return false;
		if ($("#wd").val().replace(/\ +/g,"")==""){
			$("#wd").focus();
			alert("请输入检索词!");
			return false;
		}else if ($("#wd").val().length>10){
			$("#error").html("检索词不能超过50个字符!");
			return false;
		}else{
			$("#searchBox").submit();
		}
	});
	
	$("#bookType").change(function(){
		$("#bt").val($("#bookType").val());
		$.ajax({
			type:"get",
			url:"search",
			data:$("#searchBox").serialize()
		});
	});
	$("#bookDep").change(function(){
		$("#bd").val($("#bookDep").val());
		$("#searchBox").submit();
	});
	
	$("#bookType").val($("#bt").val());
	$("#bookDep").val($("#bd").val());
});
</script>

</head>

<body style="font-family:arial;background:#fefefe">
<s:set var="datat" value="#{0:'图书',1:'光盘',2:'期刊'}"/>
	<div style="text-align:right;width:95%;margin-top:10px;"><s:property value="#session.SESSION_MANAGER_LOGIN.manName"/>, 欢迎您! <b class="sp20"> </b><a href="logout" target="_top"><span>注销登录</span></a></div>
	<div style="padding:20px;">
	<div class="slogo" id="logo"></div>
		<form action="search" method="get" id="searchBox">
			<input type="hidden" value="search" name="op" />
			<s:textfield type="hidden" name="bt" theme="simple" />
			<s:textfield type="hidden" name="bd" theme="simple" />
				<s:set value="#{0:'全文',1:'索书号',2:'条码号',3:'ISBN',4:'期刊号',5:'标题',6:'作者',7:'出版社' }" var="sts"/>
			<s:select list="sts" name="st" theme="simple"></s:select>
			<s:textfield name="wd" theme="simple" id="wd" cssClass="text" />
			<input type="submit" value="Search" class="buttons" id="submit" />
		</form>
		<div class="clearboth"></div>
	</div>
	<div style="margin-left:150px;border-left:1px #ccc solid;">
		<s:if test="#session.SESSION_SEARCH_RESULTS != null">
	<div style="margin:20px;margin-top:0">
    </div>
    	
		<div id="error"></div>
			<script type="text/javascript">
			$("#logo").attr("class","logo floatleft");
				$("#searchBox").css("margin", "20px 0px 0px 12px");
				$("#searchBox").css("float", "left");
			</script>
			<ul class="resultList">
				<s:iterator value="#session.SESSION_SEARCH_RESULTS" var="each"
					status="st">
					<li><a
						href="queryBook?op=guest&id=<s:property value="#each.bookId"/>"
						target="_black"> <s:property value="#each.bookName" />
						<s:if test="#each.dataType==2">
						: <s:property value="#each.perPeriods" />
						</s:if><s:if test="#each.bookChargePerson!=null">
						. <s:property value="#each.bookChargePerson" />
						</s:if><s:if test="#each.bookPublishing!=null">
						. <s:property value="#each.bookPublishing" /> 
						</s:if><s:if test="#each.bookPublishingTime!=null">
						. <s:property value="#each.bookPublishingTime" />
						</s:if>
					</a><br />
						<p>
							索书号/期刊号:
							<s:property value="#each.bookCallNo" /><s:property value="#each.periNo" />
							<b class="sp20"> </b> 在库数量:
							<s:property value="#each.bookCount" />
							<b class="sp20"> </b> 馆藏类型:
							<s:property value="#datat[#each.dataType]"/>
							<b class="sp20"> </b> 光盘信息:
							<s:property value="#each.bookDisk.bookName" />
						</p>
						<p>
							入库时间:
							<s:property value="#each.bookStorageTime" />
							<b class="sp20"> </b> 典藏地:
							<s:property value="#each.bookCollection" />
						</p></li>
				</s:iterator>
			</ul>
			<div style="margin-left:15px;margin-top:20px">
				<my:page pageSize="${sessionScope.SESSION_SEARCH_PAGESIZE }"
					pageNo="${sessionScope.SESSION_SEARCH_PAGENO }" url="search"
					count="${sessionScope.SESSION_SEARCH_COUNT }" op="search" wd="${sessionScope.SESSION_WD }" st="${sessionScope.SESSION_ST }"></my:page>
			</div>
		</s:if>
	</div>
</body>
</html>
